home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / Peon / PeonSDK-Win32-1.0.0.exe / {app} / PeonMain / include / IniConfigReader.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-11-17  |  3.1 KB  |  108 lines

  1.  
  2. #ifndef __INICONFIGREADER_H_
  3. #define __INICONFIGREADER_H_
  4. /*
  5. Peon - Win32 Games Programming Library
  6. Copyright (C) 2002-2005 Erik Yuzwa
  7.  
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public
  10. License as published by the Free Software Foundation; either
  11. version 2 of the License, or (at your option) any later version.
  12.  
  13. This library is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. Library General Public License for more details.
  17.  
  18. You should have received a copy of the GNU Library General Public
  19. License along with this library; if not, write to the Free
  20. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  
  22. Erik Yuzwa
  23. peon AT wazooinc DOT com
  24. */
  25.  
  26. // Precompiler options
  27. #include "peonstdafx.h"
  28.  
  29.  
  30.  
  31. namespace peon
  32. {
  33.     /**
  34.     * This object is usefull for loading and storing any information
  35.     * we might need for our game contained in an .INI file. We can
  36.     * store anything from our wanted renderer, to our application window
  37.     * size, to even some basic scripting elements.
  38.     *
  39.     * Note that this object is completely Win32-specific. It is using
  40.     * the GetPrivateProfile* family of API functions which I think are
  41.     * only available on Windows.
  42.     */
  43.     class PEONMAIN_API IniConfigReader
  44.     {
  45.  
  46.     protected:
  47.         /** our ini filename */
  48.         String    m_strFileName;     
  49.  
  50.     public:
  51.  
  52.         /**
  53.         * Constructor
  54.         * @param String - path to ini file
  55.         */
  56.         IniConfigReader(const String& strFile);
  57.  
  58.         /**
  59.         * Destructor
  60.         */
  61.         ~IniConfigReader();
  62.  
  63.         /**
  64.         * This method is responsible for grabbing any string data from our
  65.         * ini file
  66.         * @param String - our ini section
  67.         * @param String - our key name
  68.         * @param String - our default key value
  69.         * @param String& - a string object to contain our resulting data
  70.         * @return DWORD - the size of our data string
  71.         */
  72.         DWORD getString(const String sSection, const String sKey, const String sDefault, String& sReturn);
  73.  
  74.         /**
  75.         * This method is just responsible for grabbing the UINT value
  76.         * from our ini file
  77.         * @param String - section name
  78.         * @param String - key name
  79.         * @param int         - default key value
  80.         * @return UINT       - our returned key value
  81.         */
  82.         UINT getInt(String sSection, String sKeyName, int);
  83.  
  84.         /**
  85.         * This method is responsible for grabbing any boolean information
  86.         * stored in our ini file
  87.         * @param String - section name
  88.         * @param String - key name
  89.         * @param String - default key value "TRUE" or "FALSE"
  90.         * @return bool      - our actual key value
  91.         */
  92.         bool getBool(const String sSection, const String sKeyName, const String sDefault);
  93.         
  94.         /**
  95.         * This method is responsible for grabbing any float information stored
  96.         * in our INI file
  97.         * @param String sSection - section name
  98.         * @param String sKeyName - key name
  99.         * @param String sDefault - default value of float (ie. "1.0f")
  100.         * @return float - our determined float value
  101.         */
  102.         float getFloat(String sSection, String sKeyName, String sDefault);
  103.  
  104.     };
  105.  
  106. }
  107.  
  108. #endif